import Vue from 'vue'
import Vuex from 'vuex'

import token from './modules/token'
import session from './modules/session'
import common from './modules/common'

Vue.use(Vuex)

//蓝牙设置
import Bluetooth from '../components/test-print/store/bluetooth/index.js'

const store = new Vuex.Store({
	state: {
		loginInfo: {},
		sysinfo: uni.getSystemInfoSync(), //系统信息
	},
	// 模块拆分
	modules: {
		Bluetooth,
		token,
		session,
		common
	},
	// 同步修改state
	mutations: {
		updateLoginInfo: (state, loginInfo) => {
			state.loginInfo = loginInfo
		},
	},
	// 异步修改state
	actions: {
		// 登录
		login(context, loginInfo) {
			// 异步操作，例如登录请求等
			context.commit('updateLoginInfo', loginInfo);
		},
		// 注销
		logout(context, loginInfo) {
			// 异步操作，例如登录请求等
			context.commit('updateLoginInfo', {});
		}
	},
	getters: {

	}
})

export default store